<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加活动</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css-v=3.3.5.css" rel="stylesheet">
    <link href="css/font-awesome.min.css-v=4.4.0.css" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="layui-master/src/css/layui.css" rel="stylesheet">

    <script src="js/jquery.min.js-v=2.1.4"></script>
    <script src="layui-master/src/layui.js" type="text/javascript" charset="utf-8"></script>

    <link href="css/animate.min.css"
          rel="stylesheet">
    <link href="css/style.min.css-v=4.0.0.css" rel="stylesheet">
    <base target="_blank">
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
    <style>
        #zhuti {
            height: 100%;
        }
        #zhuti::before {
            background: url('img/logo1.png') no-repeat fixed center;
            content: "";
            opacity: 0.2;
            /*透明度设置*/
            width: 80%;
            height: 80%;
            position: absolute;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" id="zhuti">


                <div class="ibox-title">
                    <h3 style="font-weight: 600;margin-top: 0;">添加活动</h3>
                </div>

                <div class="ibox-content">
                    <form method="post" action="/addAct" id="bigform" autocomplete="off" class="form-horizontal">
                        <!--								第一行-->
                        <div class="form-group" style="margin-bottom: 0px;">
                            <label class="col-sm-2 control-label">活动名称</label>
                            <div class="col-sm-3">
                                <input type="text" id="activityname" name="activityname" required placeholder="请输入活动名称"
                                       class="form-control">
                            </div>

                            <label class="col-sm-2 control-label">活动方</label>
                            <div class="col-sm-4">
                                <input type="text" id="borrower" name="borrower" required placeholder="请输入活动方"
                                       class="form-control">
                            </div>
                        </div>
                        <br>

                        <!--								第二行-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">登记人</label>
                            <div class="col-sm-3">
                                <input type="text" id="handler" name="handler" required placeholder="请输入登记人"
                                       class="form-control">
                            </div>

                            <!--                            <label class="col-sm-2 control-label">登记时间</label>-->
                            <!--                            <div class="col-sm-3">-->
                            <!--                                <input type="text" id="  " name="handler" required placeholder="请输入登记时间"-->
                            <!--                                       class="form-control">-->
                            <!--                            </div>-->
                        </div>
                        <!--								分割线-->
                        <div class="hr-line-dashed"></div>


                        <!--                                第三行-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">物品编号</label>
                            <div class="col-sm-3">
                                <input type="text" id="borrowedsign" name="borrowedsign" required
                                       placeholder="借用物品的编号，以空格相隔"
                                       class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>

                        <!--								第四行-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">取走人</label>
                            <div class="col-sm-3">
                                <input type="text" id="orginizer" name="orginizer" required placeholder="请输入取走人"
                                       class="form-control">
                            </div>

                            <label class="col-sm-2 control-label">联系电话</label>
                            <div class="col-sm-4">
                                <input type="text" id="orginizer_phone" name="orginizer_phone" required
                                       placeholder="请输入您的联系电话"
                                       class="form-control">
                            </div>
                        </div>

                        <div class="form-group layui-form">
                            <label class="col-sm-2 control-label">校园卡号</label>
                            <div class="col-sm-3">
                                <input type="text" id="orginizer_card" name="orginizer_card" required
                                       placeholder="请输入取走人校园卡号"
                                       class="form-control">
                            </div>

                            <label class="col-sm-2 control-label">物品是否损坏</label>
                            <!--                            <input name="shi" type="button" style="margin-right: 1%;margin-left: 18px;" id="shi"-->
                            <!--                                   class="btn btn-primary" value="是">-->
                            <!--                            <input class="btn btn-white" id="fou" type="button" value="否">-->
                            <input type="checkbox" name="gongan" lay-skin="switch" lay-filter="switchTest1"
                                   lay-text="是|否" class="form-control">
                        </div>

                        <!--弹出的损坏情况-->
                        <div class="form-group" style="display:none" zone="100" id="sunhuai">
                            <label class="col-sm-2 control-label">损坏情况</label>
                            <div class="col-sm-3">
                                <input type="text" name="before_damage_details" placeholder="请输入损坏情况"
                                       class="form-control size">
                            </div>
                        </div>

                        <!--                       							按钮-->
                        <div class=  "form-group">
                            <div class="col-sm-3 col-sm-offset-4">

                                <input name="tijiao" type="submit" style="margin-right: 20%;" id="tijiao"
                                       class="btn btn-primary" value="提交申请">
                                <input class="btn btn-white" id="reset" type="reset" value="重新填写">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="layui/layer/layer.js" type="text/javascript" charset="utf-8"></script>

<script>
    $(document).ready(function () {
        // var ll= layui.$("input[name='gongan']").is(':checked');
        // // if( data.elem.checked==true&&$.trim(ll)==$.trim('true'))
        // if(data.elem.checked==true&&$.trim(ll)==$.trim('true'))
        // {
        //     // layer.tips('温馨提示：没有备案，无法申请', data.othis);
        //     // $("input[name='apply1']").prop("disabled", true);
        //     document.getElementById('sunhuai').style.display = 'block';
        // }
        // else
        //     if(data.elem.checked==true&&$.trim(ll)==$.trim('false'))
        // {
        //     document.getElementById('sunhuai').style.display = 'none';
        //
        // }


        // 监听是否
        layui.use('form', function () {
            var form = layui.form;
            //公安
            form.on('switch(switchTest1)', function (data) {
                // console.log(data.elem.checked);
                var ll = layui.$("input[name='gongan']").is(':checked');
                // layui.$(test).is(':checked');
                if (data.elem.checked == false && $.trim(ll) == $.trim('true')) {
                    document.getElementById('sunhuai').style.display = 'none';
                } else if (data.elem.checked == true && $.trim(ll) == $.trim('true')) {
                    document.getElementById('sunhuai').style.display = 'block';
                } else if (data.elem.checked == false && $.trim(ll) == $.trim('false')) {
                    document.getElementById('sunhuai').style.display = 'none';
                } else {
                    document.getElementById('sunhuai').style.display = 'none';
                }
                ;
            });
            //疫情办公室
            // form.on('switch(switchTest2)', function(data){
            //     var ll= layui.$("input[name='gongan']").is(':checked');
            //
            //     if( data.elem.checked==false&&$.trim(ll)==$.trim('true')){
            //         layer.tips('温馨提示：没有备案，无法申请', data.othis);
            //         $("input[name='apply1']").prop("disabled", true);
            //     }else if( data.elem.checked==true&&$.trim(ll)==$.trim('true')){
            //         $("input[name='apply1']").prop("disabled", false);//关闭属性
            //     }else if( data.elem.checked==false&&$.trim(ll)==$.trim('false')){
            //         layer.tips('温馨提示：没有备案，无法申请', data.othis);
            //         $("input[name='apply1']").prop("disabled",true);
            //     }else{
            //         $("input[name='apply1']").prop("disabled",true);
            //     };
            // });
        });

        // // 判断是否
        // $("#shi").on("click", function () {
        //     //得到input标签对象
        //     document.getElementById('sunhuai').style.display = 'block';
        //
        // })
        // // 判断是否
        // $("#fou").on("click", function () {
        //     //得到input标签对象
        //     document.getElementById('sunhuai').style.display = 'none';
        //
        // })
        //提交
        $("#bigform").on("submit", function () {
            // var huoquid = $("option:selected").text();
            // var id2 = $("option:selected").prop('id');
            var activityname = $("input[name='activityname']").val();
            var borrower = $("input[name='borrower']").val();
            var handler = $("input[name='handler']").val();
            var borrowedsign = $("input[name='borrowedsign']").val();
            var orginizer = $("input[name='orginizer']").val();
            var orginizer_phone = $("input[name='orginizer_phone']").val();
            var orginizer_card = $("input[name='orginizer_card']").val();

            var before_damage_details = $("input[name='before_damage_details']").val();

            var before_is_damage;
            if (before_damage_details == "")
                before_is_damage = 0;
            else
                before_is_damage = 1;
            //传值
            $.ajax({
                type: "POST",
                url: "/addAct",
                data: {
                    // "account": id2,
                    "activityname": activityname,
                    "borrower": borrower,
                    "handler": handler,
                    "borrowedsign": borrowedsign,
                    "organizer": orginizer,
                    "organizer_phone": orginizer_phone,
                    "organizer_card": orginizer_card,
                    "before_damage_details": before_damage_details,
                    "before_is_damage": before_is_damage,
                },
                success: function (msg) {
                    if (msg == 1) {
                        layer.alert("提交成功");
                        //提交成功后清空
                        $("input[name='activityname']").val("");
                        $("input[name='borrower']").val("");
                        $("input[name='handler']").val("");
                        $("input[name='borrowedsign']").val("");
                        $("input[name='orginizer']").val("");
                        $("input[name='orginizer_phone']").val("");
                        $("input[name='orginizer_card']").val("");
                        $("input[name='before_damage_details']").val("");

                        document.getElementById('sunhuai').style.display = 'none';

                        window.setInterval(function () {
                            top.location.href = "/index";
                        }, 1500);
                    } else {
                        layer.alert("提交失败");
                    }
                },
                error: function (nn) {
                    layer.alert("提交失败");
                    console.log(nn);
                },
            });
            return false;
        });
    });


</script>

<script src="js/bootstrap.min.js-v=3.3.5"
></script>
<script src="js/content.min.js-v=1.0.0"
></script>
<script src="js/plugins/iCheck/icheck.min.js"
></script>
</body>
</html>
